package com.cxx.purchasecharge.core.model.persistence;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.cxx.purchasecharge.core.model.BaseModel;

/**
 * 付/收款记录
 */
@Entity
@Table (name = "pc_payment")
public class Payment extends BaseModel
{
    private static final long serialVersionUID = 1L;

    private long id;
    private float paid;
    private float allUnPaid;
    private Date paidDate;

    private PaymentAccount paymentAccount;
    private Customer customer;
    private long orderId;
    private long projectId;
    private String comment;

    private long userCreatedBy;
    
    public Payment () {}

    @Id
    @GeneratedValue (strategy = GenerationType.AUTO)
    public long getId ()
    {
        return id;
    }

    public void setId (long id)
    {
        this.id = id;
    }

    @Column (nullable = false)
    public float getPaid ()
    {
        return paid;
    }

    public void setPaid (float paid)
    {
        this.paid = paid;
    }

    @Column (nullable = false)
    public float getAllUnPaid ()
    {
        return allUnPaid;
    }

    public void setAllUnPaid (float allUnPaid)
    {
        this.allUnPaid = allUnPaid;
    }

    @Column (nullable = false)
    public Date getPaidDate ()
    {
        return paidDate;
    }

    public void setPaidDate (Date paidDate)
    {
        this.paidDate = paidDate;
    }

    @ManyToOne (fetch = FetchType.LAZY, cascade =
    { CascadeType.REFRESH })
    @JoinColumn (name = "customer_id")
    public Customer getCustomer ()
    {
        return customer;
    }

    public void setCustomer (Customer customer)
    {
        this.customer = customer;
    }

    @ManyToOne (cascade =
    { CascadeType.REFRESH })
    @JoinColumn (name = "paymentAccount_id")
    public PaymentAccount getPaymentAccount ()
    {
        return paymentAccount;
    }

    public void setPaymentAccount (PaymentAccount paymentAccount)
    {
        this.paymentAccount = paymentAccount;
    }

    public long getOrderId ()
    {
        return orderId;
    }

    public void setOrderId (long orderId)
    {
        this.orderId = orderId;
    }

    public long getProjectId ()
    {
        return projectId;
    }

    public void setProjectId (long projectId)
    {
        this.projectId = projectId;
    }

    @Column (length = 1024)
    public String getComment ()
    {
        return comment;
    }

    public void setComment (String comment)
    {
        this.comment = comment;
    }

    public long getUserCreatedBy()
    {
        return userCreatedBy;
    }

    public void setUserCreatedBy(long userCreatedBy)
    {
        this.userCreatedBy = userCreatedBy;
    }

}
